﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace Protobuf_Gui.Domain
{
    /// <summary>
    /// service SessionNotify
    /// {
    ///     methods
    /// }
    /// </summary>
    [Serializable]
    [ContainType(typeof(PbServiceMethod),"Service method")]
    public class PbService : ProtocolElement
    {
        public PbService(string name) : base(name)
        {
            Methods = new List<PbServiceMethod>();
        }

        public List<PbServiceMethod> Methods { get; set; }

        public override TreeNode ToTreeNode(TreeNode root)
        {
            throw new NotImplementedException();
        }

        public override void ToFile(TextWriter writer, uint nesting)
        {
            string tabs = Tabs(nesting);
            writer.WriteLine("{0}service {1}", tabs, Name);
            writer.WriteLine(tabs + "{");
            foreach (var method in Methods)
            {
                method.ToFile(writer, nesting + 1);
            }
            writer.WriteLine(tabs + "}");
        }
    }
}